<?php
namespace app\core\widget;

use think\Controller;

class Area extends Controller
{

    public function _initialize()
    {
        parent::_initialize();
    }


    public function area($name, $value = '')
    {
        $value_e = explode(',', $value);
        $data = [
            'province' => empty($value_e[0]) ? 0 : $value_e[0],
            'city' => empty($value_e[1]) ? 0 : $value_e[1],
            'district' => empty($value_e[2]) ? 0 : $value_e[2],
        ];
        $this->assign($data);
        $this->assign('value', $value);
        $this->assign('name', $name);
        return $this->fetch('core@widget/area');
    }

    public function getDistrict($pid = 0)
    {
        $list = db('district')->where(['pid' => $pid])->select();
        return $list;
    }

}
